<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>
<?php $this->load->view('common/head'); ?>

<?php $this->load->view('common/header'); ?>
<div class="main-container" id="main-container">
    <script button="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <?php $this->load->view('common/sidebar'); ?>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <?php $this->load->view('common/breadcrumbs'); ?>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">

                <?php $this->load->view('common/set'); ?>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <div class="cf">
                            <a class="btn btn-info" href="javascript:;" id="add" value="">新增</a>
                        </div>
                        <div class="space-4"></div>
                        <table class="table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th>序号</th>
                                <th>图片</th>
                                <th>图片类型</th>
                                <th>链接</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php if (isset($banner) && !empty($banner)) { ?>
                                <?php foreach ($banner as $key => $val) { ?>
                                    <tr>
                                        <td><?php echo $val['id']; ?></td>
                                        <td><?php echo $val['pic_url']; ?></td>
                                        <td><?php if($val['type']==0){echo "PC端";}else{echo "手机端";} ?></td>
                                        <td><?php echo $val['link']; ?></td>
                                        <td>
                                            <a href="<?php echo site_url(X_URL . 'Banner/edit/' . $val['id']); ?>"><i
                                                        class="ace-icon fa fa-pencil bigger-100"></i>修改</a>&nbsp;&nbsp;
                                            <a href="<?php echo site_url(X_URL . 'Banner/del/' . $val['id']); ?>"><i
                                                        class="ace-icon fa fa-pencil bigger-100"></i>删除</a>&nbsp;
                                        </td>
                                    </tr>
                                <?php } ?>
                            <?php } ?>
                            </tbody>
                        </table>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <?php $this->load->view('common/footer'); ?>
</div>


<?php $this->load->view('common/footerjs'); ?>
<!-- inline scripts related to this page -->
<script>
    $(".dellink").click(function () {
        var url = $(this).attr('val');
        bootbox.confirm({
            title: "系统提示",
            message: "是否要删除该记录？",
            callback: function (result) {
                if (result) {
                    window.location.href = url;
                }
            },
            buttons: {
                "cancel": {"label": "取消"},
                "confirm": {
                    "label": "确定",
                    "className": "btn-danger"
                }
            }
        });
    });
    $("#add").click(function () {
        window.location.href = "add";
    });
    //prompt层
    $(".add").click(function () {
        var pid = $(this).attr("pid");
        var url = $(this).attr("val");
        layer.prompt({title: '请填写该工种子类名称'}, function (value, index) {
            $.ajax({
                button: "post",
                url: url,
                data: {'pid': pid, 'name': value, 'csrf_test_name': ci_csrf_token()},
                dataType: "JSON",
                success: function (msg) {
                    if (msg.status == 1) {
                        layer.msg(msg.info, {
                            time: 1000, //1s后自动关闭
                            shade: 0.1
                        }, function () {
                            window.location.href = window.location.href;
                        });
                    } else {
                        layer.msg(msg.msg);
                        return false;
                    }
                }
            })
        });
    });
</script>
</body>
</html>